//
// Description: 853. 有边数限制的最短路
// Created by Loading on 2022/5/21.
//

#include <bits/stdc++.h>

using namespace std;

constexpr int N = 510, M = 10010;
constexpr int INF = 0x3f3f3f3f;

// 距离数组以及备份数组（防止更新串联）
int dist[N], backup[N];
int n, m, k;

// 结构体存储边
struct Edges {
    // 由a到b存在一条权值为w的边
    int a, b, w;
} edges[M];

// bellman_ford 算法求有边数限制的最短路
void bellman_ford() {
    memset(dist, 0x3f, sizeof dist);
    dist[1] = 0;

    for (int i = 0; i < k; ++i) {
        // 防止更新距离时的串联，每次遍历要备份
        memcpy(backup, dist, sizeof dist);
        for (int j = 0; j < m; ++j) {
            int a = edges[j].a;
            int b = edges[j].b;
            int w = edges[j].w;
            dist[b] = min(dist[b], backup[a] + w);
        }
    }

    // 存在负权边，不能使用 dist[n] == INF 判断最短路不存在，根据数据范围选择一个较大值即可
    if (dist[n] > INF / 2) {
        puts("impossible");
    } else {
        cout << dist[n] << endl;
    }
}

int main() {
    cin >> n >> m >> k;
    for (int i = 0; i < m; ++i) {
        int x, y, z;
        cin >> x >> y >> z;
        edges[i] = {x, y, z};
    }

    bellman_ford();

    return 0;
}
